package com.ruoyi.jms;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping(value = "/jmsController")
public class JmsController {

    @Autowired
    @Qualifier("jmsTemplate")
    private JmsTemplate jmsTemplate;

    @Autowired
    private HelloWord myHelloService;

    @RequestMapping(value = "/sendMsg", method = RequestMethod.GET)
    @ResponseBody
    public Object loginOut(HttpServletRequest req, HttpServletResponse resp) {
        jmsTemplate.convertAndSend("hello world   " + System.currentTimeMillis());//发送消息
        System.err.println(myHelloService.sayHello("world"));//JMSRPC调用
        return null;
    }
}